<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
    <meta http-equiv="expires" content="0" />
    <title>FaceCat</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">  
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>  
    <script src="js/bootstrap.min.js"></script>  
</head>
<body>
    <canvas id="mycanvas" width="1000" height="700" style="position: fixed; left: 0px; top: 0px;"/>
    <script type="text/javascript" src="facecat.js"></script>
    <script type="text/javascript">
        let canvas = document.getElementById("mycanvas"); //绘图区域
        let context = canvas.getContext("2d"); //绘图上下文
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        let gPaint = new FCPaint(); //绘图对象
        gPaint.canvas = canvas;
        scaleCanvas(gPaint);
        //判断是否移动端
        gPaint.isMobile = isMobileMode();
        if (gPaint.isMobile) {
            gPaint.scaleFactorX = 2.5;
            gPaint.scaleFactorY = 2.5;
        }
        
        gPaint.defaultUIStyle = "dark";
        addDefaultEvent(canvas, gPaint);
        /*
         * 重置大小
         */
        let resizeAll = function () {
            try {
                canvas.width = document.documentElement.clientWidth;
                canvas.height = document.documentElement.clientHeight;
                scaleCanvas(gPaint);
                updateViewDefault(gPaint.views);
            } catch (err) {
                
            }
            invalidate(gPaint);
        };
        /*
        * 监听大小改变
        */
        window.onresize = function () {
            resizeAll();
        };

        /*
        * 旋转监听
        */
        window.onorientationchange = function () {
            resizeAll();
        };
        //解析加载XML
        let xml = `<?xml version="1.0" encoding="UTF-8"?>
  <html xmlns="facecat">
    <body>
      <div dock="fill" backcolor="rgb(140,192,81)">
        <div name="Div" text="Div" location="368,127" size="247,326" align="center" vertical-align="middle" backcolor="rgb(170,178,189)" cornerradius="10">
          <input type="text" name="TextBox" location="14,18" size="220,45" cornerradius="0" bordercolor="rgb(0,0,0)" backcolor="rgb(42,48,72)" font="Default,30.0" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnAC" text="AC" location="14,69" size="55,48" font="Default,18.0" backcolor="rgb(62,72,95)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnAddSub" text="+/-" location="69,69" size="55,48" font="Default,18.0" backcolor="rgb(62,72,95)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnMod" text="%" location="124,69" size="55,48" font="Default,18.0" backcolor="rgb(62,72,95)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnDivide" text="÷" location="179,69" size="55,48" font="Default,18.0" backcolor="rgb(254,159,11)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum7" text="7" location="14,117" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum8" text="8" location="69,117" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum9" text="9" location="124,117" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnMulti" text="×" location="179,117" size="55,48" font="Default,18.0" backcolor="rgb(254,159,11)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum4" text="4" location="14,165" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum5" text="5" location="69,165" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum6" text="6" location="124,165" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnSub" text="-" location="179,165" size="55,48" font="Default,18.0" backcolor="rgb(254,159,11)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum1" text="1" location="14,213" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum2" text="2" location="69,213" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum3" text="3" location="124,213" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnAdd" text="+" location="179,213" size="55,48" font="Default,18.0" backcolor="rgb(254,159,11)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnNum0" text="0" location="14,261" size="110,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnDot" text="." location="124,261" size="55,48" font="Default,18.0" backcolor="rgb(93,103,121)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
          <input type="button" name="btnResult" text="=" location="179,261" size="55,48" font="Default,18.0" backcolor="rgb(254,159,11)" bordercolor="rgb(0,0,0)" textcolor="rgb(255,255,255)"/>
        </div>
      </div>
    </body>
  </html>`;
        renderFaceCat(gPaint, xml);
    </script>
</body>
</html>
